import java.util.HashMap;
import java.util.Map;

public class SolutionInterview16_2 {

    Map<String,Integer> map=new HashMap<>();

    public SolutionInterview16_2(String[] book) {
        for (String s : book) {
            map.put(s,map.getOrDefault(s,0)+1);
        }
    }

    public int get(String word) {
        return map.getOrDefault(word,0);
    }

    public static void main(String[] args) {
        SolutionInterview16_2 solutionInterview16_2=new SolutionInterview16_2(new String[]{"i", "have", "an", "apple", "he", "have", "a", "pen"});
        System.out.println(solutionInterview16_2.get("you"));
        System.out.println(solutionInterview16_2.get("have"));
    }
}
